home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 3006 / 3006.xpi / chrome / dwhelper.jar / content / ythq-widgets.xml < prev   
Extensible Markup Language  |  2010-01-15  |  7KB  |  249 lines

  1. <?xml version="1.0"?>
  2. <!-- *****************************************************************************
  3.  *            Copyright (c) 2006-2007 Michel Gutierrez. All Rights Reserved.
  4.  ****************************************************************************** -->
  5. <!DOCTYPE bindings SYSTEM "chrome://dwhelper/locale/dwhelper.dtd" >
  6.  
  7. <bindings xmlns="http://www.mozilla.org/xbl"
  8.     xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
  9.     xmlns:html="http://www.w3.org/1999/xhtml"
  10.     xmlns:xbl="http://www.mozilla.org/xbl">
  11.  
  12.     <binding id="YTHQConfiguration" extends="widgets.xml#widget">
  13.  
  14.         <xbl:content xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
  15.             <hbox flex="1">
  16.                 <tree anonid="xTree" hidecolumnpicker="true" flex="3" onselect="this.parentNode.parentNode.selected()">
  17.                     <treecols>
  18.                         <treecol label="&ythq.column.type;" flex="1"/>
  19.                         <treecol label="&ythq.column.format;" flex="1"/>
  20.                         <treecol label="&ythq.column.video;" flex="3"/>
  21.                         <treecol label="&ythq.column.audio;" flex="2"/>
  22.                     </treecols>
  23.                     <treechildren anonid="xChildren"/>
  24.                 </tree>
  25.                 <vbox flex="1"   style="height: 60px; overflow: auto;">
  26.                     <spacer flex="1"/>
  27.                     <button anonid="xEnableBut" label="&ythq.label.enable;" collapsed="true" oncommand="this.parentNode.parentNode.parentNode.changeState(1)"/>
  28.                     <button anonid="xDisableBut" label="&ythq.label.disable;" collapsed="true" oncommand="this.parentNode.parentNode.parentNode.changeState(0)"/>
  29.                     <button anonid="xUpBut" label="&ythq.label.up;" collapsed="true" oncommand="this.parentNode.parentNode.parentNode.move(1)"/>
  30.                     <button anonid="xDownBut" label="&ythq.label.down;" collapsed="true" oncommand="this.parentNode.parentNode.parentNode.move(0)"/>
  31.                 </vbox>
  32.             </hbox>
  33.             <children style="display: none;"/>
  34.         </xbl:content>
  35.  
  36.         <implementation>
  37.  
  38.             <constructor>
  39.                 <![CDATA[
  40. this.formats={
  41.     6: { type: "6", format: "FLV", video: "480x270", audio: "mono" },
  42.     13: { type: "13", format: "3GP", video: "176x144", audio: "mono" },
  43.     17: { type: "17", format: "3GP", video: "176x144", audio: "stereo" },
  44.     18: { type: "18", format: "MP4", video: "480x360", audio: "stereo" },
  45.     34: { type: "34", format: "FLV", video: "320x240", audio: "mono" },
  46.     35: { type: "35", format: "FLV", video: "640x360", audio: "mono" },
  47.     22: { type: "22", format: "MP4", video: "1280x720", audio: "stereo" },
  48.     37: { type: "37", format: "MP4", video: "1920x1080", audio: "stereo" },
  49. }
  50. this.formatsCount=0;
  51. for(var i in formats)
  52.     this.formatsCount++;
  53. this.build("");
  54.                 ]]>
  55.             </constructor>
  56.             
  57.             <property name="value">  
  58.                 <setter>
  59.                 <![CDATA[
  60. this.build(val);
  61.                 ]]> 
  62.                 </setter>
  63.                 <getter>
  64.                 <![CDATA[
  65. var values=[];
  66. var item=this.xChildren.firstChild;
  67. while(item) {
  68.     if(item.getAttribute("properties")!="format-disabled")
  69.         values.push(item.getAttribute("format"));
  70.     item=item.nextSibling;
  71. }
  72. return values.join(",");
  73.                 ]]> 
  74.                 </getter>
  75.             </property>
  76.             
  77.             <property name="selectedFormat">  
  78.                 <setter>
  79.                 <![CDATA[
  80. if(val==null)
  81.     this.xTree.view.selection.select(-1);
  82. else {
  83.     var items=this.xChildren.childNodes;
  84.     for(var i=0;i<items.length;i++) {
  85.         if(items.item(i).getAttribute("format")==val) {
  86.             this.xTree.view.selection.select(i);
  87.             return;
  88.         }
  89.     }
  90. }
  91.                 ]]> 
  92.                 </setter>
  93.                 <getter>
  94.                 <![CDATA[
  95. if(this.xTree.currentIndex<0)
  96.     return null;
  97. return this.xChildren.childNodes.item(this.xTree.currentIndex).getAttribute("format");
  98.                 ]]> 
  99.                 </getter>
  100.             </property>
  101.             
  102.             <method name="build">
  103.                 <parameter name="aValue"/>
  104.                 <body>
  105.                 <![CDATA[
  106. var selection=this.selectedFormat;
  107. while(this.xChildren.firstChild)
  108.     this.xChildren.removeChild(this.xChildren.firstChild);
  109. var values=aValue.split(",");
  110. var enabledValues={};
  111. for(var i in values) {
  112.     this.buildRow(values[i],true);
  113.     enabledValues[values[i]]="";
  114. }
  115. for(var i in this.formats) {
  116.     if(enabledValues[i]==null)
  117.         this.buildRow(i,false); 
  118. }
  119. this.selectedFormat=selection;
  120. this.updateButtons();
  121.                 ]]>
  122.                 </body>
  123.             </method>
  124.  
  125.             <method name="buildRow">
  126.                 <parameter name="format"/>
  127.                 <parameter name="enabled"/>
  128.                 <body>
  129.                 <![CDATA[
  130. if(this.formats[format]) {
  131.     var treeItem=document.createElement("treeitem");
  132.     treeItem.setAttribute("format",format);
  133.     this.xChildren.appendChild(treeItem);
  134.     var treeRow=document.createElement("treerow");
  135.     treeItem.appendChild(treeRow);
  136.     var treeCell=document.createElement("treecell");
  137.     treeCell.setAttribute("label",this.util.getFText("label.high-quality-prefix2",[this.formats[format].type],1));
  138.     treeRow.appendChild(treeCell);
  139.     var treeCell=document.createElement("treecell");
  140.     treeCell.setAttribute("label",this.formats[format].format);
  141.     treeRow.appendChild(treeCell);
  142.     var treeCell=document.createElement("treecell");
  143.     treeCell.setAttribute("label",this.formats[format].video);
  144.     treeRow.appendChild(treeCell);
  145.     var treeCell=document.createElement("treecell");
  146.     treeCell.setAttribute("label",this.formats[format].audio);
  147.     treeRow.appendChild(treeCell);
  148.     this.applyState(treeItem,enabled);
  149. }
  150.                 ]]>
  151.                 </body>
  152.             </method>
  153.  
  154.             <method name="selected">
  155.                 <body>
  156.                 <![CDATA[
  157. this.updateButtons();
  158.                 ]]>
  159.                 </body>
  160.             </method>
  161.                         
  162.             <method name="updateButtons">
  163.                 <body>
  164.                 <![CDATA[
  165. if(this.xTree.currentIndex<0) {
  166.     this.xUpBut.setAttribute("collapsed","true");
  167.     this.xDownBut.setAttribute("collapsed","true");
  168.     this.xEnableBut.setAttribute("collapsed","true");
  169.     this.xDisableBut.setAttribute("collapsed","true");
  170. } else {
  171.     if(this.xTree.currentIndex>0)
  172.         this.xUpBut.setAttribute("collapsed","false");
  173.     else
  174.         this.xUpBut.setAttribute("collapsed","true");
  175.     if(this.xTree.currentIndex<this.formatsCount-1)
  176.         this.xDownBut.setAttribute("collapsed","false");
  177.     else
  178.         this.xDownBut.setAttribute("collapsed","true");
  179.     var selItem=this.xChildren.childNodes.item(this.xTree.currentIndex);
  180.     if(selItem.getAttribute("properties")=="format-disabled") {
  181.         this.xEnableBut.setAttribute("collapsed","false");
  182.         this.xDisableBut.setAttribute("collapsed","true");
  183.     } else {
  184.         this.xEnableBut.setAttribute("collapsed","true");
  185.         this.xDisableBut.setAttribute("collapsed","false");
  186.     }
  187. }
  188.                 ]]>
  189.                 </body>
  190.             </method>
  191.  
  192.             <method name="changeState">
  193.                 <parameter name="state"/>
  194.                 <body>
  195.                 <![CDATA[
  196. var selItem=this.xChildren.childNodes.item(this.xTree.currentIndex);
  197. this.applyState(selItem,state);
  198. this.fireEvent("changed");
  199.                 ]]>
  200.                 </body>
  201.             </method>
  202.             
  203.             <method name="applyState">
  204.                 <parameter name="element"/>
  205.                 <parameter name="state"/>
  206.                 <body>
  207.                 <![CDATA[
  208. if(state)
  209.     element.removeAttribute("properties");
  210. else
  211.     element.setAttribute("properties","format-disabled");
  212. element=element.firstChild;
  213. while(element) {
  214.     this.applyState(element,state);
  215.     element=element.nextSibling;
  216. }
  217.                 ]]>
  218.                 </body>
  219.             </method>
  220.  
  221.  
  222.             <method name="move">
  223.                 <parameter name="direction"/>
  224.                 <body>
  225.                 <![CDATA[
  226. var selItem=this.xChildren.childNodes.item(this.xTree.currentIndex);
  227. var selection=this.selectedFormat;
  228. var refItem;
  229. if(direction) {
  230.     refItem=selItem.previousSibling;
  231. } else {
  232.     refItem=selItem.nextSibling.nextSibling;
  233. }
  234. this.xChildren.removeChild(selItem);
  235. this.xChildren.insertBefore(selItem,refItem);
  236. this.selectedFormat=selection;
  237.  
  238. this.fireEvent("changed");
  239.                 ]]>
  240.                 </body>
  241.             </method>
  242.  
  243.  
  244.         </implementation>
  245.                 
  246.     </binding>
  247.  
  248. </bindings>
  249.